<?php 
	
	header('Content-type: text/json');
	
	$method = $_POST['method'];

	switch( $method ){
		// 通过sid自动登录
		case 'autoLogin':
			$sid = $_POST['sid'];
			$data = array(
				'result' => 1,
				'sid' => 'A4D9eS9212Mkhn2WH3W',
				'user' => array(
					'id' => 323,
					'avatar' => 'img/avatar/avatar-male.png',
					'sex' => 'male',
					'name' => '亮亮',
					'count_get' => 23,
					'count_throw' => 10,
					'unReadMsg' => 12
				)
			);
			echo json_encode($data);
			break;
		// 登录
		case 'login':
			$name = $_POST['name'];
			$pwd = $_POST['pwd'];

			$data1 = array(
				'result' => 1,
				'sid' => 'A4D9eS92fds932WH3W',
				'user' => array(
					'id' => 323,
					'avatar' => 'img/avatar/avatar-male.png',
					'sex' => 'male',
					'name' => '亮亮',
					'count_get' => 23,
					'count_throw' => 10,
					'unReadMsg' => 12
				)
			);

			$data2 = array(
				'result' => 0,
				'errMsg' => '用户名不存在'
			);
			echo json_encode($data1);
			break;

		// 获取个人信息和系统信息
		case 'requestInfo' : 
			$data = array(
				'result' => 1,
				'user' => array(
					'count_throw' => 21,
					'count_get' => 3,
					'hasGot' => 323,
					'hasThrow' => 421
				),
				'sys' => array(
					'maleOL' => 321,
					'fmaleOL' => 21,
					'bottles_unread' => 322
				)
			);
			echo json_encode($data);
			break;

		// 丢瓶子	
		case 'throwBottle':
			$data = array(
				'result' => 1,
				'count_throw' => 9
			);
			echo json_encode($data);
			break;
		// 捡瓶子 新瓶子
		case 'getBottle':
			// if ($id === '_GUEST_') {
			// 	echo 'Your are a guest';
			// }else{
			// 	echo 'Your got one';
			// }

			$bottle = array(
                    'result' => 1,
                    'count_get' => 21,
                    'bottle' => array(
                        'bID'  => 241,
                        'role_t' => array(
                        	'sex' => 'male',
	                        'avatar' => 'img/avatar/avatar-male.png',
	                        'id' => 2432,
	                        'name'=> '李富贵'
                        ),                 
                        'msgList'=> array(
                        	array(
                        		'type' => 't',
                        		'time' => 1394712320221,
                        		'msg' => '高富帅斤斤计较说飞范德萨'
                        	)
                        )
                    )
                );
            echo json_encode($bottle);
			break;

		// 获取瓶子列表
		case 'requestList':
			$list = array(
				array(
					'bID' => 2522,
					'tID' => 322,
					'tAvatar' => 'res/12.jpg',
					'tTime' => 1394717320221,
					'tSex' => 'fmale',
					'tName' => '李二蛋',
					'lastMsg' => '好像去旅游'
				),
				array(
					'bID' => 25122,
					'tID' => 3222,
					'tAvatar' => 'res/11.jpg',
					'tTime' => 1394717320232,
					'tSex' => 'fmale',
					'tName' => '方法蛋',
					'lastMsg' => '好范德萨范德萨旅游'
				),
				array(
					'bID' => 25422,
					'tID' => 3252,
					'tAvatar' => 'res/13.jpg',
					'tTime' => 1394717321221,
					'tSex' => 'male',
					'tName' => '阿尔',
					'lastMsg' => '好范德萨范德萨游'
				),
				array(
					'bID' => 25322,
					'tID' => 32112,
					'tAvatar' => 'res/100.jpg',
					'tTime' => 1394717220221,
					'tSex' => 'fmale',
					'tName' => '各应我',
					'lastMsg' => '好范德萨游'
				)
			);
			echo json_encode($list);
			break;

		// 通过id获取瓶子
		case 'requestBottle':
			$bottle = array(
                    'result' => 1,
                    'bottle' => array(
                        'bID'  => 241,
                        'role_t' => array(
                        	'sex' => 'male',
	                        'avatar' => 'img/avatar/avatar-male.png',
	                        'id' => 2432,
	                        'name'=> '李富贵'
                        ),
                        'role_g' => array(
                        	'id' => 123,
	                        'name' => '刘二蛋',
	                        'avatar' => 'img/avatar/avatar-fmale.png',
	                        'sex' => 'fmale'
                        ),                 
                        'msgList'=> array(
                        	array(
                        		'type' => 't',
                        		'time' => 1394712320221,
                        		'msg' => '高富帅斤斤计较说飞范德萨'
                        	),
                        	array(
                        		'type' => 'g',
                        		'time' => 1394717420221,
                        		'msg' => '高富发大水飞范德萨'
                        	),
                        	array(
                        		'type' => 't',
                        		'time' => 13947174321221,
                        		'msg' => '换地方哈电话沟通'
                        	),
                        	array(
                        		'type' => 'g',
                        		'time' => 1394732120221,
                        		'msg' => '人气旺让7u影明白您萨'
                        	),
                        	array(
                        		'type' => 'g',
                        		'time' => 1392117420221,
                        		'msg' => '人气旺fdsa影明白您萨'
                        	),
                        	array(
                        		'type' => 't',
                        		'time' => 1394717420221,
                        		'msg' => '人fa明白您萨'
                        	)
                        )
                    )
                );
            echo json_encode($bottle);
			break;
		
		// 发送信息 回复
		case 'msg':
			$bid = $_POST['bid'];
			$msg = $_POST['msg'];
			$id = $_POST['id'];

			$data = array(
				'result' => 1,
				'msgInfo' => array(
					'id' => $id,
					'msg' => $msg
				)
			);
			echo json_encode($data);
	}

?>